<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<% String context = request.getContextPath(); %>
<html>
<head>
    <title>条件表达式</title>
    <link rel="stylesheet" type="text/css" href="<%=context %>/Source/lib/ligerUI/skins/ligerui-icons.css" />
<link rel="stylesheet" type="text/css" href="<%=context %>/Source/lib/ligerUI/skins/Aqua/css/ligerui-all.css" />
    <style type="text/css">
        #operator li{padding:2px 20px;}
        #operator li:hover{cursor: pointer;background:#BEE1F6;}
    </style>
    
</head>
<body>
    <div style="width: 460px;margin: 0 auto;margin-top:10px;">
        <div style="width:350px;float: left;">
            <div id="mainGrid"></div>
        </div>
        <ul id="operator" style="height:167px;border:1px solid #99BBE8;float: left;overflow-y: scroll;margin-left: 30px;">
            <li>+</li>
            <li>-</li>
            <li>*</li>
            <li>/</li>
            <li>%</li>
            <li>=</li>
            <li>==</li>
            <li>!=</li>
            <li>></li>
            <li><</li>
            <li>>=</li>
            <li><=</li>
            <li>(</li>
            <li>)</li>
            <li>!</li>
            <li>||</li>
            <li>&</li>
        </ul>
        <div style="clear:both;padding:10px 0px;">
            <textarea id="express" rows="5" cols="73" style="border:1px solid #99BBE8;"></textarea>
            <table style="margin-top:5px;">
                <tr>
                    <td>下步节点：</td>
                    <td>
                        <select id="node"  class="liger-textbox" style="width: 250px;display:inline">
                            <option value="">--请选择下部节点--</option>
                        </select>
                    </td>
                </tr>
            </table>
        </div>
    </div>
</body>
<script src="<%=context %>/gooflow/jquery.min.js"></script>
<script src="<%=context %>/Source/lib/ligerUI/js/ligerui.all.js"></script>
<script>
var path = '<%=context %>';
var processId= '${processId}';
        var nodeStr = sessionStorage.getItem("nodeStr");
        var nodeObj = JSON.parse(nodeStr);
        $(function(){
            /*
            * 加载下步节点
            * */
            for(var node in nodeObj){
                var nodeChild = nodeObj[node];
                if(nodeChild.type != "start round"){
                    $("#node").append("<option value='"+node+"'>"+nodeChild.name+"</option>");
                }
            }
            /*
            * 初始化参与判断的参数列表
            * */
            $("#mainGrid").ligerGrid({
                columns: [
                    { display: 'id', name: 'id', hide: true, width: 60 },
                    { display: '序号', width: 40, render: function (rowData, rowindex, value, column, rowid, page, pagesize) { return (page - 1) * pagesize + rowindex + 1; } },
                    { display: '属性名称', name: 'parameterName', align: 'center', width: 160 },
                    { display: '属性类型', name: 'typeName', align: 'center', width: 140 }
                ],
                url:path +'/flow/processParameter/getJudgeData?processId='+processId,
                height:200,
                heightDiff: -1,
                usePager:false,
                onSelectRow:function(processParameter){
                    createExpress(processParameter.parameterName);
                }
            });
            /*
            * 点击，添加运算符
            * */
            $("#operator li").click(function(){
                createExpress($(this).text());
            });
         });

        /*
        * 拼接表达式
        * */
        function createExpress(text){
            var value = $("#express").val();
            $("#express").val(value+=text);
        }

        /*
        * 获取表达式和下步节点
        * */
        var isEmpty = "";
        function getExpress(){
            isEmpty = "";
            if($("#express").val() != "" && $("#node").val() ==""){
                $.ligerDialog.warn("请输入下步节点");
                isEmpty = "next";
            }
            if($("#express").val() == "" && $("#node").val() !=""){
                $.ligerDialog.warn("请输入条件表达式");
                isEmpty = "express";
            }
            var value = {"express":$("#express").val(),"nextNode":$("#node").find("option:selected").text(),"nodeValue":$("#node").val()};
            return value;
        }
      </script>
</html>
